public class Solution {
    //最长回文子串(中心拓展算法)
    private static int max_length(String s) {
        int n = s.length();
        int ret = 0;
        //每一个i位置为中心点向两边扩散
        for(int i = 0; i < n; i++) {
            //长度为奇数
            int left = i - 1;
            int right = i + 1;
            while(left >= 0 && right < n && s.charAt(left) == s.charAt(right)) {
                right++;
                left--;
            }
            ret = Math.max(ret,right - left - 1);

            //长度为偶数
            left = i ;
            right = i + 1;
            while(left >= 0 && right < n && s.charAt(left) == s.charAt(right)) {
                right++;
                left--;
            }
            ret = Math.max(ret,right - left - 1);
        }
        return ret;
    }
    //买卖股票好时机
    private static int max_price(int[] prices) {
        int ret = 0;
        int prevMin = prices[0];
        for(int i = 0; i < prices.length; i++) {
            ret = Math.max(ret, prices[i] - prevMin);
            prevMin = Math.min(prevMin,prices[i]);
        }
        return ret;
    }
}
